# coding: utf-8
import sys,os
sys.path.append('..')
import numpy as np
from common.util import preprocess, create_co_matrix, cos_similarity, ppmi

text = ''
with open((os.path.abspath(os.path.join(os.getcwd(),"corpus.txt"))),'r',encoding='utf-8') as f:
    contents=f.readlines()
    for line in contents:
        text = text + line
corpus, word_to_id, id_to_word = preprocess(text)
vocab_size = len(word_to_id)
C = create_co_matrix(corpus, vocab_size)
W = ppmi(C)

# np.set_printoptions(precision=3)  # 有效位数为3位
# print('covariance matrix')
# print(C)
# print('-'*50)
print('PPMI')
print(W.ndim)

